﻿namespace Visitor
{
    internal class ListVisitor : VisitorAbstract
    {
        private string currentDir = "";


        public override void Visit(File file)
        {
            Console.WriteLine($"{this.currentDir}/{file}");
        }

        public override void Visit(Directory directory)
        {
            Console.WriteLine($"{this.currentDir}/{directory}");
            var saveDir = this.currentDir;
            currentDir = $"{currentDir}/{directory.GetName()}";

            foreach (var item in directory)
            {
                item.Accept(this);
            }

            currentDir = saveDir;
        }
    }
}
